import { pushResponseInterceptor } from 'lfun-bg-comp';

pushResponseInterceptor('get:/school/v1/system/menu', r => {
  const path = window.location.pathname;
  if ((path.includes('/city/') || path.includes('/county/')) && path.includes('/kg/') && path.includes('/unit/')) {
    return {
      app_name: '园所信息管理系统',
      menu: [
        {
          power_name: '园所信息管理（规划）',
          power_url: '/planning',
          power_code: 'planning',
          power_type: 'menu',
        },
        {
          power_name: '园所信息管理（学校）',
          power_url: '/school',
          power_code: 'school',
          power_type: 'menu',
        },
        {
          power_name: '园所配置管理',
          power_code: 'config',
          power_type: 'root',
          children: [
            {
              power_name: '年级管理',
              power_url: '/grade',
              power_code: 'grade',
              power_type: 'menu',
            },
            {
              power_name: '班级管理',
              power_url: '/class',
              power_code: 'class',
              power_type: 'menu',
            },  {
              power_name: '班级管理',
              power_url: '/class',
              power_code: 'class',
              power_type: 'menu',
            },
          ],
        },
      ],
    };
  }
  if ((path.includes('/city/') || path.includes('/county/')) && path.includes('/k12/') && path.includes('/unit/')) {
    return {
      app_name: '中小学信息管理系统',
      menu: [
        {
          power_name: '中小学信息管理（规划）',
          power_url: '/planning',
          power_code: 'planning',
          power_type: 'menu',
        },
        {
          power_name: '中小学信息管理（学校）',
          power_url: '/school',
          power_code: 'school',
          power_type: 'menu',
        },
        {
          power_name: '中小学配置管理',
          power_code: 'config',
          power_type: 'root',
          children: [
            {
              power_name: '年级管理',
              power_url: '/grade',
              power_code: 'grade',
              power_type: 'menu',
            },
            {
              power_name: '班级管理',
              power_url: '/class',
              power_code: 'class',
              power_type: 'menu',
            },
          ],
        },
      ],
    };
  }
  if (
    (path.includes('/city/') || path.includes('/county/')) &&
    path.includes('/vocational/') &&
    path.includes('/unit/')
  ) {
    return {
      app_name: '职高信息管理系统',
      menu: [
        {
          power_name: '职高信息管理（规划）',
          power_url: '/planning',
          power_code: 'planning',
          power_type: 'menu',
        },
        {
          power_name: '职高信息管理（学校）',
          power_url: '/school',
          power_code: 'school',
          power_type: 'menu',
        },
        {
          power_name: '职高配置管理',
          power_code: 'config',
          power_type: 'root',
          children: [
            {
              power_name: '年级管理',
              power_url: '/grade',
              power_code: 'grade',
              power_type: 'menu',
            },
            {
              power_name: '班级管理',
              power_url: '/class',
              power_code: 'class',
              power_type: 'menu',
            },
          ],
        },
      ],
    };
  }
  if (path.includes('/school/') && path.includes('/kg/') && path.includes('/unit/')) {
    return {
      app_name: '园所信息管理系统',
      menu: [
        {
          power_name: '园所信息管理（学校）',
          power_url: '/school',
          power_code: 'school',
          power_type: 'menu',
        },
        {
          power_name: '园所配置管理',
          power_code: 'config',
          power_type: 'root',
          children: [
            {
              power_name: '年级管理',
              power_url: '/grade',
              power_code: 'grade',
              power_type: 'menu',
            },
            {
              power_name: '班级管理',
              power_url: '/class',
              power_code: 'class',
              power_type: 'menu',
            },
            {
              power_name: '课程管理',
              power_url: '/course',
              power_code: 'course',
              power_type: 'menu',
            },
          ],
        },
      ],
    };
  }
  if (path.includes('/school/') && path.includes('/k12/') && path.includes('/unit/')) {
    return {
      app_name: '中小学信息管理系统',
      menu: [
        {
          power_name: '中小学信息管理（学校）',
          power_url: '/school',
          power_code: 'school',
          power_type: 'menu',
        },
        {
          power_name: '中小学配置管理',
          power_code: 'config',
          power_type: 'root',
          children: [
            {
              power_name: '年级管理',
              power_url: '/grade',
              power_code: 'grade',
              power_type: 'menu',
            },
            {
              power_name: '班级管理',
              power_url: '/class',
              power_code: 'class',
              power_type: 'menu',
            },
            {
              power_name: '课程管理',
              power_url: '/course',
              power_code: 'course',
              power_type: 'menu',
            },
          ],
        },
      ],
    };
  }
  if (path.includes('/school/') && path.includes('/vocational/') && path.includes('/unit/')) {
    return {
      app_name: '职高信息管理系统',
      menu: [
        {
          power_name: '职高信息管理（学校）',
          power_url: '/school',
          power_code: 'school',
          power_type: 'menu',
        },
        {
          power_name: '职高配置管理',
          power_code: 'config',
          power_type: 'root',
          children: [
            {
              power_name: '年级管理',
              power_url: '/grade',
              power_code: 'grade',
              power_type: 'menu',
            },
            {
              power_name: '班级管理',
              power_url: '/class',
              power_code: 'class',
              power_type: 'menu',
            },
            {
              power_name: '课程管理',
              power_url: '/course',
              power_code: 'course',
              power_type: 'menu',
            },
            {
              power_name: '专业管理',
              power_url: '/major',
              power_code: 'major',
              power_type: 'menu',
            },
          ],
        },
      ],
    };
  }
  if (path.includes('/teacher/')) {
    return {
      app_name: '教职工信息管理系统',
      menu: [
        {
          power_name: '新教职工管理',
          power_code: 'onboarding',
          power_type: 'root',
          children: [
            {
              power_name: '新教职工入职',
              power_url: '/onboarding',
              power_code: 'onboarding',
              power_type: 'menu',
            },
            {
              power_name: '新教职工审批',
              power_url: '/onboarding/approve',
              power_code: 'approve',
              power_type: 'menu',
            },
          ],
        },
        {
          power_name: '在职教职工管理',
          power_code: 'employed',
          power_type: 'root',
          children: [
            {
              power_name: '在职教职工管理',
              power_url: '/employed',
              power_code: 'employed',
              power_type: 'menu',
            },
            {
              power_name: '新教职工审批',
              power_url: '/employed/approve',
              power_code: 'employedapprove',
              power_type: 'menu',
            },
            {
              power_name: '变动管理',
              power_url: '/employed/workchange',
              power_code: 'employedworkchange',
              power_type: 'menu',
            },
            {
              power_name: '借入信息管理',
              power_url: '/employed/borrowin',
              power_code: 'employedworkborrowin',
              power_type: 'menu',
            },
            {
              power_name: '借出信息管理',
              power_url: '/employed/borrowout',
              power_code: 'employedworkborrowout',
              power_type: 'menu',
            },
            {
              power_name: '调入信息管理',
              power_url: '/employed/transferin',
              power_code: 'employedworktransferin',
              power_type: 'menu',
            },
            {
              power_name: '调出信息管理',
              power_url: '/employed/transferout',
              power_code: 'employedworktransferout',
              power_type: 'menu',
            },
          ],
        },
        {
          power_name: '非在职教职工管理',
          power_code: 'nonemployed',
          power_type: 'root',
          children: [
            {
              power_name: '离退休信息管理',
              power_url: '/nonemployed/retire',
              power_code: 'employedworkretire',
              power_type: 'menu',
            },
          ],
        },
        {
          power_name: '系统管理',
          power_code: 'trchsys',
          power_type: 'root',
          children: [
            {
              power_name: '系统配置',
              power_url: '/trchsys/config',
              power_code: 'trchsysconfig',
              power_type: 'menu',
            },
            {
              power_name: '任务管理',
              power_url: '/trchsys/task',
              power_code: 'trchsystask',
              power_type: 'menu',
            },
          ],
        },
      ],
    };
  }
  if (path.includes('/student/')) {
    return {
      app_name: '学生信息管理系统',
      menu: [
        {
          power_name: '新学生信息管理',
          power_code: '/newstudent',
          power_type: 'root',
          children: [
            {
              power_name: '新生入学管理',
              power_url: '/newstudent',
              power_code: 'newstudent',
              power_type: 'menu',
            },
            {
              power_name: '分班管理',
              power_url: '/newstudent/classroom',
              power_code: 'newstudent_classroom',
              power_type: 'menu',
            },
            {
              power_name: '届别管理',
              power_url: '/newstudent/academia',
              power_code: 'newstudent_academia',
              power_type: 'menu',
            },
          ],
        },
        {
          power_name: '在校学生信息管理',
          power_code: 'instudent',
          power_type: 'root',
          children: [
            {
              power_name: '在校学生信息管理',
              power_url: '/instudent',
              power_code: 'instudent',
              power_type: 'menu',
            },
            {
              power_name: '转学管理',
              power_url: '/transfer',
              power_code: 'instudent_transfer',
              power_type: 'menu',
            },
            {
              power_name: '转入信息管理',
              power_url: '/instudent/checkin',
              power_code: 'instudent_checkin',
              power_type: 'menu',
            },
            {
              power_name: '转出信息管理',
              power_url: '/instudent/checkout',
              power_code: 'instudent_checkout',
              power_type: 'menu',
            },
            {
              power_name: '异动管理',
              power_url: '/instudent/innerTransfer',
              power_code: 'instudent_innerTransfer',
              power_type: 'menu',
            },
            {
              power_name: '临时就读',
              power_url: '/instudent/emporaryBorrowing',
              power_code: 'instudent_emporaryBorrowing',
              power_type: 'menu',
            },
          ],
        },
        {
          power_name: '毕业生信息管理',
          power_url: '/graduation',
          power_code: 'graduation',
          power_type: 'menu',
        },
      ],
    };
  }

  return {};
});
